# coding: utf-8
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

from .settings import HISTORY_DB_FILE

engine = create_engine(f"sqlite:///{HISTORY_DB_FILE.as_posix()}", echo=False)
DbBase = declarative_base()


def create_session():
    return sessionmaker(bind=engine)()


def init_create_table() -> None:
    DbBase.metadata.create_all(bind=engine, checkfirst=True)
